package b_TreeSet;

import java.util.Comparator;
import java.util.TreeSet;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package b_TreeSet
 * @date 2024/4/11 下午7:00
 */
public class test01 {
    public static void main(String[] args) {
        TreeSet<String> treeSet=new TreeSet<>();
        treeSet.add("A");
        treeSet.add("M");
        treeSet.add("S");
        treeSet.add("D");
        treeSet.add("V");
        treeSet.add("H");
        treeSet.add("T");
        treeSet.add("E");
        System.out.println(treeSet);
        TreeSet<Person> treeset=new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge()- o2.getAge();
            }
        });
        treeset.add(new Person("张三",18));
        treeset.add(new Person("李四",19));
        treeset.add(new Person("张麻子",20));

        System.out.println(treeset);
    }
}
